package com.dora.pattern.singleton;

/**
 * 懒惰单例
 *
 * @author hanchen
 * @date 2024/02/20
 */
public class LazySingleton {
    private static LazySingleton instance;

    private LazySingleton() {
        // 私有构造方法
    }
    public static LazySingleton getInstance() {
        if (instance == null) {
            synchronized (LazySingleton.class) {
                if (instance == null) {
                    instance = new LazySingleton();
                }
            }
        }
        return instance;
    }
}
